package com.flick.user.ctrl;

import com.flick.po.User;
import com.flick.user.dao.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author flick on 2017/5/9.
 * @version 1.0
 */
@RestController
public class UserCtrl {
    @Autowired
    private DiscoveryClient discoveryClient;
    @Autowired
    private UserRepository userRepository;

    @GetMapping("/{id}")
    public User get(@PathVariable String id){
        return userRepository.findOne(id);
    }
    @GetMapping("/instance-info")
    public ServiceInstance showInfo(){
        return discoveryClient.getLocalServiceInstance();
    }
}
